# -*- coding: utf-8 -*-
# @Time    : 2020/3/18 0:45
# @Author  : Sunny
# @Site    : 
# @File    : auth.py
# @Software: PyCharm
# @WeChat public address : 程序猿与python之间的秘密

from django.utils.deprecation import MiddlewareMixin
from web import models


class AuthMiddleWare(MiddlewareMixin):
    def process_request(self, request):
        user_id = request.session.get('user_id', 0)
        user_obj = models.User.objects.filter(id=user_id).first()
        request.tracer = user_obj
